package simulator.position;

public class Point {
	private final double x;
	private final double y;
	
	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	public int getX() {
		return (int) Math.round(x);
	}
	
	public int getY() {
		return (int) Math.round(y);
	}
	
	public double getPreciseX() {
		return x;
	}
	
	public double getPreciseY() {
		return y;
	}
	public double getDistanceTo(Point other){
		return Math.sqrt(Math.pow(other.getPreciseX()-this.getPreciseX(),2)+Math.pow(other.getPreciseY()-this.getPreciseY(), 2));
	}
	public int[] getCoordinates() {
		int[] position = { getX(), getY() };
		return position;
	}
	
	public String toString() {
		return "(" + getX() + "," + getY() + ")";
	}
	
	@Override
	public int hashCode() {
		return toString().hashCode();
	}
	
	@Override
	public boolean equals(Object other) {
		if (!(other instanceof Point))
			return false;
		Point otherPoint = (Point) other;
		return otherPoint.getX() == this.getX() && otherPoint.getY() == this.getY();
	}
}
